<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"  xmlns:ui="http://java.sun.com/jsf/facelets"                        
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"      >
    <h:head>     
        <link href="#{facesContext.externalContext.requestContextPath}/resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="#{facesContext.externalContext.requestContextPath}/resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <link href="#{facesContext.externalContext.requestContextPath}/resources/css/menu.css" rel="stylesheet" type="text/css" />
        <title>Blue Pumpkin Admin Page</title>
    </h:head>
    <h:body>
        <div class="main_body_admin" >
            <div class="separator_div"/>
            <div class="admin_logo"/>

            <h:form id="frmMain">
                <p:menubar style="text-align: center" >
                     <p:menuitem value="Event" actionListener="#{naviagtionControl.redirectToEventPage()}" > </p:menuitem> 
                    <p:menuitem value="Prize" actionListener="#{naviagtionControl.redirectToPrizePage()}" ></p:menuitem> 
                    <p:menuitem value="User"  style="color: blueviolet; font-weight: bold" styleClass="admin_menu_current" ></p:menuitem> 
                    <p:menuitem value="FAQ"  actionListener="#{naviagtionControl.redirectToFAQsPage()}" ></p:menuitem> 
                    <p:menuitem value="Contact" actionListener="#{naviagtionControl.redirectToContactPage()}"  ></p:menuitem> 
                    <p:menuitem value="Registration" actionListener="#{naviagtionControl.redirectToRegistrationPage()}" ></p:menuitem> 
                    <p:menuitem value="Winner" actionListener="#{naviagtionControl.redirectToWinnerPage()}"  ></p:menuitem> 
                    <p:menuitem value="Comment" actionListener="#{naviagtionControl.redirectToCommentsPage()}"  ></p:menuitem> 
                    <p:submenu label="#{userControl.user.fullName}"    >
                         <p:menuitem value="Edit Profile" actionListener="#{userControl.redirectToLogonUserPage()}" ></p:menuitem> 
                        <p:menuitem value="Log out" actionListener="#{userControl.logout()}"  ></p:menuitem> 
                    </p:submenu>


                </p:menubar>
            </h:form>

            <div class="content_display">
                <h:form>
                    <p:toolbar>
                        <p:toolbarGroup>
                            <p:commandButton value="Add User" actionListener="#{userControl.redirectToAddUserPage()}"/>
                            <p:commandButton value="View Users" actionListener="#{userControl.redirectToListUserPage()}" />
                            <p:commandButton value="Change Password" actionListener="#{userControl.redirectToChangePasswordPage()}" />

                        </p:toolbarGroup>
                    </p:toolbar>
                </h:form>
                <p:spacer height="5px" />



                <h:form enctype="multipart/form-data">
                    <p:panel id="panel" header="Edit User Profile" style="width: 99%; ">

                        <h:panelGrid columns="2" style="width: 80%">

                            <h:outputLabel value="UserName:" for="userName" />
                            <p:inputText id="userName" value="#{userControl.user.username}" label="UserName">
                                <f:validateLength minimum="6"/>
                                <p:message id="msu" for="userName" display="UserName is not be empty "/>
                            </p:inputText>


                            <h:outputLabel value="Sex:" for="sex" />
                            <p:selectOneRadio id="options"  value="#{userControl.user.genger}" required="true" requiredMessage="Choose your gender">  
                                <f:selectItem itemLabel="Male" itemValue="true" />  
                                <f:selectItem itemLabel="Female" itemValue="false" />    
                            </p:selectOneRadio>

                            <h:outputLabel value="FullName:" for="fullName" />
                            <p:inputText id="fullName" value="#{userControl.user.fullName}" label="FullName" required="true">
                                <f:validateLength minimum="1"/>
                                <p:message id="msfn" for="fullName" display="FullName is not be empty"/>
                            </p:inputText>

                            <h:outputLabel value="Avatar:" for="avatar" />
                            <p:fileUpload id="avatar" mode="advanced" update="preview" sizeLimit="1000000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" 
                                          auto="true"  fileUploadListener="#{userControl.handleFileUploadEditProfile}" />  
                            <h:outputLabel value="Avatar:" for="preview" />
                            <h:commandLink id="preview" value="" ><img src="#{userControl.user.avatar}" height="100" width="70" /></h:commandLink>

                            <h:outputLabel value="Birthday:" for="dob" />  
                            <p:calendar id="dob"  mindate="#{userControl.minDate()}" maxdate="#{userControl.maxDOB()}" 
                                        value="#{userControl.user.dob}"  required="true" requiredMessage="Choose your Birthday"/>


                            <h:outputLabel value="Phone" for="phone" />                                
                            <p:inputMask id="phone" value="#{userControl.user.phone}" mask="999-999-9999" 
                                         validatorMessage="Phone is not valid" >
                                <p:message for="phone"/>
                            </p:inputMask>

                            <h:outputLabel value="Address:" for="address" />
                            <p:inputText id="address" value="#{userControl.user.address}" title="Address" >
                                <f:validateLength minimum="5"/>
                                <p:message id="msad" for="address" display="Address must be minium 5 char "/>
                            </p:inputText>

                            <h:outputLabel value="Email:" for="email" />
                            <p:inputText id="email" value="#{userControl.user.email}" required="true" 
                                         label="Email" validatorMessage="#{userControl.user.email} is not valid">
                                <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
                                <p:message for="email" />
                            </p:inputText>

                            <h:outputLabel value="JoinedDate:" for="joinedDate" />
                            <p:calendar id="joinedDate" mindate="#{userControl.minDate()}"  maxdate="#{userControl.currentDate()}" 
                                        value="#{userControl.user.joinedDate}" required="true" requiredMessage="Choose your Joinedate"/>

<!--                            <h:outputLabel value="IsAdmin:" for="isadmin" />                                
                            <p:selectOneRadio id="isadmin" value="#{userControl.user.isAdmin}">  
                                <f:selectItem itemLabel="Yes" itemValue="true" />  
                                <f:selectItem itemLabel="No" itemValue="false"  />    
                            </p:selectOneRadio>

                            <h:outputLabel value="IsActive:" for="isactive" />
                            <p:selectOneRadio id="isactive" value="#{userControl.user.active}">  
                                <f:selectItem itemLabel="Yes" itemValue="true" />  
                                <f:selectItem itemLabel="No" itemValue="false" />    
                            </p:selectOneRadio>-->

                            <h:outputLabel value="DepartmentName:" for="departmentName" />
                            <p:selectOneMenu value="#{userControl.user.department}" id="departmentName" required="true">
                                <f:selectItem itemLabel="Select One" itemValue=""/>
                                <f:selectItem itemLabel="Manager" itemValue="Manager"/>
                                <f:selectItem itemLabel="Maketing" itemValue="MaKeting"/>
                                <f:selectItem itemLabel="IT" itemValue="IT"/>
                                <f:selectItem itemLabel="Accounting" itemValue="Accounting"/>
                                <f:selectItem itemLabel="Sales" itemValue="Sales"/>
                                <f:selectItem itemLabel="Protection" itemValue="Protection"/>
                                <p:message for="departmentName" display="Please choose Department!!!"/>
                            </p:selectOneMenu>
                            <div/>
                            <p:messages id="mgs" autoUpdate="true" />
                            <p:commandButton value="Update" actionListener="#{userControl.editUserPorfile()}" update="panel, mgs" />
                            <p:commandButton value="Cancel" actionListener="#{userControl.redirectToListUserPage()}"  />

                        </h:panelGrid>
                    </p:panel>                                                                        
                </h:form>



            </div>
        </div>
    </h:body>
</html>
